/* 
 * File:   FiltreNB.cpp
 * Author: amouro-m
 * 
 * Created on 15 mai 2010, 11:13
 */

#include "FiltreNB.hpp"
#include "FractalPrinter.h"

FiltreNB::FiltreNB():
Filtre("Filtre N&B")
{}

FiltreNB::~FiltreNB() {}

void
FiltreNB::compute(SDL_Surface* area, const unsigned int x, const unsigned int y) const
{
    Uint8 red, green, blue, composition;
    Uint32 color = FractalPrinter::getpixel(area, x,y);
    SDL_GetRGB(color, area->format, &red, &green, &blue);

    composition = (red + green + blue) / 3;
    color = SDL_MapRGB(area->format,composition,composition,composition);
    FractalPrinter::putpixel(area, x, y, color);
}